﻿@using XiaoYuStock.Model
@using XiaoYuStock.Model.Models
@using XiaoYuStock.Model.Request
@using XiaoYuStock.WebApp.Controls
@model PagedList<XiaoYuStock.Model.Entities.TradeDataModel>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section PageSpecificStyleSheetIncludes{
<style type="text/css">
    select { width:80px}
</style>
}
<div class="row-fluid">
    <div class="span4">
        <div>
            <a class="btn blue thickbox" title='新增' href="@Url.Action("Create")?TB_iframe=true&height=400&width=600"><i class="icon-plus icon-white"></i> 新增</a>
            <a class="btn red" id="delete" href="javascript:;"><i class="icon-trash icon-white"></i> 删除</a>
        </div>
    </div>
    <div class="span9">
        @using (Html.BeginForm(null, null, null, FormMethod.Get, new { id = "search", @class = "form-inline" }))
        {
            <div class="dataTables_filter">
                <label><button type="submit" class="btn" id="btnSearch">搜索 <i class="icon-search"></i></button></label>
                <label>
                    <span>起始日期：</span>
                    @Html.TextBox("BeginDate", null, new { @class = "m-wrap small" })--@Html.TextBox("EndDate", null, new { @class = "m-wrap small" })
                </label>
                <label>
                    <span>自选股票：</span>
                    @Html.DropDownList("CustomerCode")

                </label>
                <label>
                    <span>账号类型：</span>
                    <select name="ShareAccount" id="ShareAccount" ><option value="">不限</option><option value="A">A</option><option value="B">B</option></select>

                </label>
            </div>
        }
    </div>
</div>

<table class="table table-striped table-hover " id="tableHistory">
    <thead>
        <tr>
            <th>
                日期
            </th>
            <th>
                项目
            </th>
            <th>
                账号类型
            </th>
            
            <th>
                类型
            </th>
            <th>
               价格
            </th>
            <th>数量</th>
            <th>开</th>
            <th>收</th>
            <th>大</th>
            <th>小</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var p in Model)
        {
            <tr>
                <td>
                    @p.TradeTime.ToString("yyyy-MM-dd")
                </td>
                <td class="blue">
                    &nbsp;@p.ShareCode【@p.ShareName】
                        </td>
                <td>@p.ShareAccount</td>
                       
                        <td>@p.TradeStatusDes</td>
                        <td>
                           @p.TradeAmount
                        </td>   
                 <td>@p.TradeCount</td>
                <td>@p.OpenPrice</td>
                <td>@p.ClosePrice</td>
                <td>@p.MaxPrice</td>
                <td>@p.MinPrice</td>                    
                        <td>
                            <a class="btn mini purple thickbox" title='编辑' href="@Url.Action("Edit", new { id = p.Id })?TB_iframe=true&height=400&width=600">
                                <i class="icon-edit"></i>
                                编辑
                            </a>
                        </td>
                    </tr>
        }
    </tbody>
</table>

<div class="dataTables_paginate paging_bootstrap pagination">
    @Html.Pager(Model, new PagerOptions() { ShowTotalItemCount = true, AutoHide = false })
</div>
<script>
    $(function () {
        $("#btnUpdate").click(function () {
            var t = $("#tableHistory td.blue:first").text();
            $.post("/HistoryData/GetHistoryUpdate", { sharesCodes: t.trim() }, function (data) {
                if (data.status)
                {
                    $("#btnSearch").click();
                }
            });
        });

        $('#tableHistory').dataTable({
            searching: false,
            bFilter: false,
            bLengthChange: false,
            paging: false,
            bInfo: false,
            bPaginate: false,
            "bSort": false
        });

    });
   
    var dates = $("#BeginDate, #EndDate").datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "+0",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onSelect: function (selectedDate) {
            var option = this.id == "startDate" ? "minDate" : "maxDate",
            instance = $(this).data("datepicker"),
            date = $.datepicker.parseDate(
                instance.settings.dateFormat ||
                $.datepicker._defaults.dateFormat,
                selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }
    });

</script>

